package com.jdz.gxq.info.admin.tax.action;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.jdz.gxq.info.admin.tax.bo.Tax;
import com.jdz.gxq.info.admin.tax.form.TaxListForm;
import com.jdz.gxq.info.admin.tax.service.TaxService;
import com.jdz.gxq.info.common.action.CommonAction;
import com.jdz.gxq.info.common.bo.PageBean;

public class TaxListAction extends CommonAction {

	private TaxService taxService = null;

	public ActionForward doExecute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws java.lang.Exception {

		TaxListForm taxListForm = (TaxListForm) form;

		String enterpriseName = taxListForm.getEnterpriseName();

		int totalCount = taxService.getTaxsCount(enterpriseName);

		int currentPage = taxListForm.getPageIndex();

		PageBean pageBean = new PageBean(totalCount, currentPage);

		taxListForm.setPageIndex(pageBean.getCurrentPage());

		Map<String, Object> params = new HashMap<String, Object>();

		// 分页用
		params.put("startRow", pageBean.getPageStartRow() - 1);
		params.put("rowSize", pageBean.getPageSize());
		params.put("enterpriseName", enterpriseName);

		List<Tax> taxList = taxService.getTaxs(params);

		request.setAttribute("taxList", taxList);
		request.setAttribute("pageBean", pageBean);

		return mapping.findForward("success");
	}

	public void setTaxService(TaxService taxService) {
		this.taxService = taxService;
	}
}
